package org.qs.webservice.util;

import java.util.List;

public final class StringUtils
{
  public static boolean isNullOrEmpty(String s)
  {
    if (s == null) {
      return true;
    }
    if ("".equals(s.trim())) {
      return true;
    }
    return false;
  }

  public static String listToString(List<String> list, String separate)
  {
    String temp = "";
    for (String s : list) {
      temp = temp + separate + s;
    }
    if (temp.length() > separate.length()) {
      return temp.substring(separate.length());
    }
    return "";
  }

  public static String toStringWithoutNull(String s)
  {
    if (s == null) {
      return "";
    }
    return s;
  }

  public static String convert(String str, int len)
  {
    return str.substring(0, str.length() - len) + "." + 
      str.substring(str.length() - len);
  }

  public static boolean isBlank(String str)
  {
    int strLen;
    if ((str == null) || ((strLen = str.length()) == 0))
      return true;
    //int strLen;
    for (int i = 0; i < strLen; i++) {
      if (!Character.isWhitespace(str.charAt(i))) {
        return false;
      }
    }
    return true;
  }

  	public static boolean isNotBlank(String str){
  		int strLen;
  		if ((str == null) || ((strLen = str.length()) == 0))
  			return false;
  		// int strLen;
  		for (int i = 0; i < strLen; i++) {
  			if (!Character.isWhitespace(str.charAt(i))) {
  				return true;
  			}
  		}
  		return false;
  }

  	public static String getStringFour(int num) {
	    if (num < 10) {
	    	return "000" + num;
	    }
	    if (num < 100) {
	    	return "00" + num;
	    }
	    if (num < 1000) {
	    	return "0" + num;
	    }
    	if (num < 10000) {
    		return num+"";
    	}
    	return "0000";
  	}
	public static String getStringSix(int num) {
		if (num < 10) {
	    	return "00000" + num;
	    }
	    if (num < 100) {
	    	return "0000" + num;
	    }
	    if (num < 1000) {
	    	return "000" + num;
	    }
	    if (num < 10000) {
	    	return "00" + num;
	    }
	    if (num < 100000) {
	    	return "0" + num;
	    }
	   
    	if (num < 1000000) {
    		return num+"";
    	}
    	return "000000";
	}
}